/*******************************************************************************
 *
 *    Copyright (c) Baina Info Tech Co. Ltd
 *
 *    Test_VoiceControl
 *    
 *    VoiceFactory
 *    TODO File description or class description.
 *
 *    @author: zuochen
 *    @since:  2011-6-17
 *    @version: 1.0
 *
 ******************************************************************************/

package com.phone.voice.control;

import android.content.Context;
import android.media.AudioManager;

/**
 * VoiceFactory of Test_VoiceControl.
 * 
 * @author zuochen
 * 
 */

public class VoiceFactory {
	public static <T extends VoiceControl> T getInstance(
			Class<? extends VoiceControl> voiceControl) {
		T aT = null;
		try {
			aT = (T) Class.forName(voiceControl.getName()).newInstance();

		} catch (final InstantiationException e) {
			e.printStackTrace();
		} catch (final IllegalAccessException e) {
			e.printStackTrace();

		} catch (final ClassNotFoundException e) {
			e.printStackTrace();
		}
		return aT;
	}

	public static VoiceControl getInstance(int type, Context context) {
		VoiceControl aT = null;
		switch (type) {
		case AudioManager.STREAM_RING:
			aT = new RingtoneControl(context);
			break;
		case AudioManager.STREAM_NOTIFICATION:
			aT = new NotificationControl(context);
			break;
		case AudioManager.STREAM_MUSIC:
			aT = new MusicControl(context);
			break;
		case AudioManager.STREAM_ALARM:
			aT = new AlarmControl(context);
			break;
		case AudioManager.STREAM_VOICE_CALL:
			aT = new CallVoiceControl(context);
			break;
		case AudioManager.STREAM_SYSTEM:
			aT = new SystemControl(context);
			break;
		}
		return aT;
	}
}
